﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
using Microsoft.Reporting.WinForms;

namespace AppAcc.Views.BaoCaoChungTu
{
    public partial class FormBaoCaoNhatKyThuTien : Form
    {
        public FormBaoCaoNhatKyThuTien()
        {
            InitializeComponent();
        }
        private string SoTK1,SoTK2;
        private DateTime d1, d2;
        public FormBaoCaoNhatKyThuTien(string tk1,string tk2,DateTime dt1,DateTime dt2)
        {
            InitializeComponent();
            SoTK1 = tk1;
            SoTK2 = tk2;
            d1 = dt1;
            d2 = dt2;
        }
        private void FormBaoCaoNhatKyThuTien_Load(object sender, EventArgs e)
        {
            try
            {
                this.pr_NhatKyThuTienMatTableAdapter.Fill(this.dS_NhatKyThuTienMat.pr_NhatKyThuTienMat, SoTK1, SoTK2, d1, d2);
                ReportParameter[] rptParams = new ReportParameter[]
            {
                new ReportParameter("SoTK",SoTK1), 
                new ReportParameter("TKDU",SoTK2), 
                new ReportParameter("TuNgay",Convert.ToString(d1)),
                new ReportParameter("DenNgay",Convert.ToString(d2)),
            };
                reportViewer1.LocalReport.SetParameters(rptParams);
                this.reportViewer1.RefreshReport();
                //this.reportViewer1.RefreshReport();
            }
            catch (Exception)
            {
                this.pr_NhatKyThuTienMatTableAdapter.Fill(this.dS_NhatKyThuTienMat.pr_NhatKyThuTienMat, SoTK1, SoTK2, d1, d2);
                ReportParameter[] rptParams = new ReportParameter[]
            {
                new ReportParameter("SoTK",SoTK1), 
                new ReportParameter("TKDU",SoTK2), 
                new ReportParameter("TuNgay",Convert.ToString(d1)),
                new ReportParameter("DenNgay",Convert.ToString(d2)),
            };
                reportViewer1.LocalReport.SetParameters(rptParams);
                this.reportViewer1.RefreshReport();
                //this.reportViewer1.RefreshReport();
                //throw;
            }
            //this.pr_NhatKyThuTienMatTableAdapter.Fill(this.dS_NhatKyThuTienMat.pr_NhatKyThuTienMat, SoTK1, SoTK2, d1, d2);
            //ReportParameter[] rptParams = new ReportParameter[]
            //{
            //    new ReportParameter("SoTK",SoTK1), 
            //    new ReportParameter("TKDU",SoTK2), 
            //    new ReportParameter("TuNgay",Convert.ToString(d1)),
            //    new ReportParameter("DenNgay",Convert.ToString(d2)),
            //};
            //reportViewer1.LocalReport.SetParameters(rptParams);
            //this.reportViewer1.RefreshReport();
            //this.reportViewer1.RefreshReport();
        }
    }
}
